package com.szxy.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @Author:zwer
 * @Date:2020/4/17 15:40
 * @Description:com.szxy.bean
 * @Version:1.0
 **/
public class EmployeeService {

    public Employee getEmpByEmpId(int empId){
        List<Employee> list = new ArrayList<>();
        list.add(new Employee(1, "张三", 20000));
        list.add(new Employee(5, "李四", 1880));
        list.add(new Employee(3, "王五", 3000));
        for (Employee emp : list) {
            if (emp.getId() == empId) {
                return emp;
            }
        }
        return null;
    }

    public Optional<Employee> getEmpOptionalByEmpId(int empId){
        List<Employee> list = new ArrayList<>();
        list.add(new Employee(1, "张三", 20000));
        list.add(new Employee(5, "李四", 1880));
        list.add(new Employee(3, "王五", 3000));
        for (Employee emp : list) {
            if (emp.getId() == empId) {
                return Optional.of(emp);
            }
        }
        return Optional.empty();
    }


}
